//
//  HomeCell.swift
//  HR
//
//  Created by zhenyu on 17/6/5.
//  Copyright © 2017年 allblue. All rights reserved.
//

import UIKit

class HomeCell: UITableViewCell {
  
  weak var title: UILabel!
  weak var leftDes: UILabel!
  weak var rightDes: UILabel!
  weak var rightImage: UIImageView!
  
  class func identifier()-> String {
    return "HomeCell"
  }
  
  // MARK: - LifeCycle
  override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
    super.init(style: style, reuseIdentifier: reuseIdentifier)
    selectionStyle = .none
    setViews()
  }
  
  required init?(coder aDecoder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
  }
  
  override func awakeFromNib() {
    super.awakeFromNib()
    // Initialization code
  }
  
  override func setSelected(_ selected: Bool, animated: Bool) {
    super.setSelected(selected, animated: animated)
    // Configure the view for the selected state
  }
  
  
  // MARK: - SetViews
  func setViews() {
    title = UILabel().then({ (l) in
      contentView.addSubview(l)
      l.text = "1. 贵州省遵义高速公路管理处40人;\n2. 贵州省都匀高速公路管理处19人;\n3. 贵州省凯里高速公路管理处29人;\n4. 贵州省铜仁高速公路管理处23人;\n5. 贵州省毕节高速公路管理处32人;\n6. 贵州省水城高速公路管理处24人;\n7. 贵州省兴义高速公路管理处23人;"
      l.numberOfLines = 0
      l.textColor = Color.font
      l.font = HRFont(size: 16)
    }).then({ (l) in
      l.snp.makeConstraints({ (make) in
        make.top.equalTo(15)
        make.left.equalTo(18)
        make.right.equalTo(contentView.snp.right).offset(-18)
      })
    })
    
    leftDes = UILabel().then({ (l) in
      contentView.addSubview(l)
      l.text = "综合· 贵州考试网"
      l.numberOfLines = 0
      l.textColor = Color.font
      l.font = HRFont(size: 12)
    }).then({ (l) in
      l.snp.makeConstraints({ (make) in
        make.top.equalTo(title.snp.bottom).offset(15)
        make.left.equalTo(title.snp.left)
        make.bottom.equalTo(contentView.snp.bottom).offset(-10)
      })
    })
    
    rightDes = UILabel().then({ (l) in
      contentView.addSubview(l)
      l.text = "发布时间：10 分钟前"
      l.numberOfLines = 0
      l.textColor = Color.font
      l.font = HRFont(size: 12)
    }).then({ (l) in
      l.snp.makeConstraints({ (make) in
        make.top.equalTo(title.snp.bottom).offset(15)
        make.right.equalTo(title.snp.right)
      })
    })
    
    rightImage = UIImageView(image: #imageLiteral(resourceName: "h_cell")).then({ (i) in
      contentView.addSubview(i)
      i.snp.makeConstraints({ (make) in
        make.top.equalTo(contentView)
        make.right.equalTo(contentView)
      })
    })
    
    _ = UIView().then { (v) in
      addSubview(v)
      v.backgroundColor = Color.line
    }.then({ (v) in
      v.snp.makeConstraints({ (make) in
        make.top.equalTo(leftDes.snp.bottom).offset(9.5)
        make.left.right.equalTo(self)
        make.height.equalTo(0.5)
      })
    })
  }
}
